package com.hqyj.servletdemo.dao.impl;

import cn.hutool.extra.tokenizer.engine.mynlp.MynlpEngine;
import com.hqyj.servletdemo.dao.UsersDao;
import com.hqyj.servletdemo.util.DruidDBUtil;
import com.hqyj.servletdemo.util.MyUtil;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class UsersDaoImpl implements UsersDao {
    @Override
    public boolean login(String identify, String password) {
        String sql = "select * from users where mobile = ? and password=? and flag=0";
        List argList = new ArrayList();
        ResultSet rs = null;
        try{
            password = MyUtil.encodePasswordByMd5Salt(password);
            argList.add(identify);
            argList.add(password);
            rs = DruidDBUtil.executeQuery(sql,argList);
            //如果rs.next==true,说明找到了登录用户，则登录成功！
            if(rs.next()){
                return true;
            }
            return false;
        }catch(Exception ex){
            ex.printStackTrace();
            return false;
        }finally{
            DruidDBUtil.closeAll();
        }
    }
}
